﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Ppt = Microsoft.Office.Interop.PowerPoint;

namespace ObjectModel.PowerPoint.RulesModel
{
    /// <summary>
    /// A serializable class that caches a live reference to a PowerPoint slide object.
    /// </summary>
    public class CachedSlide
    {
        Ppt.Slide mSlide;

        public CachedSlide() { } // Parameterless constructor needed for serialization.

        public CachedSlide(Ppt.Slide slide)
        {
            Slide = slide;
        }

        public ResolvableSlide StoredSlide { get; set; } // Holds serializable slide details.

        [XmlIgnore]
        public Ppt.Slide Slide
        {
            get
            {
                if (mSlide == null)
                    mSlide = StoredSlide.Resolve() as Ppt.Slide;

                return mSlide;
            }

            set
            {
                mSlide = value;
                StoredSlide = new ResolvableSlide(value);
            }
        }
    }
}
